<template>
	<view>
		<!-- 商品详情渲染区域 -->
		<block class="goods" v-for="(goods, i) in goodslist" :key="i">
			<goods
				:goods="goods"
			/>
		</block>
		
	</view>
</template>
<script>
	export default {
		data() {
			return {
				showNumberBox:false,
				// 请求参数对象
				queryObj: {
					// 查询关键词
					query: '',
					// 商品分类Id
					cid: '',
					// 页码值
					pagenum: 1,
					// 每页显示多少条数据
					pagesize: 10
				},
				//商品列表
				goodslist:{}
			};
		},
		onLoad(options) {
			// 将页面参数转存到 this.queryObj 对象中
			this.queryObj.query = options.query || ''
			this.queryObj.cid = options.cid || ''
			this.getGoodsList()
		},
		methods: {
			async getGoodsList() {
				// 发起请求
				const {
					data: res
				} = await uni.$http.get('/api/public/v1/goods/search', this.queryObj)
				if (res.meta.status !== 200) return uni.$showMsg()
				// 为数据赋值
				this.goodslist = res.message.goods
			}
		}
	}
</script>

<style lang="scss">
	.goodslist {
		padding: 2px 10px;
	}
	.goods-item {
		display: flex;
		border-bottom: 1px solid #f0f0f0;
		justify-content: space-between;
	}

	image {
		width: 260rpx;
	}

	.goods-item-left {
		margin-left: 10px;
	}

	.goods-item-right {
		display: flex;
		width: 400rpx;
		flex-direction: column;
		justify-content: space-between;
		.goods-item-price {
			color: red;
		}

	}
</style>
